home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / initToolSettings.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  6.7 KB  |  210 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  08 Nov 2000
  22. //  Author:         bwk
  23. //
  24. //  Description:
  25. //      This script initializes the Tool Settings.  Initialization involves
  26. //        determining the initial Tool Settings preferences, creating the UI
  27. //        and setting the initial visibility.
  28. //
  29.  
  30. proc createToolSettings(string $parent)
  31. //
  32. //    Description:
  33. //        Create the Tool Settings for within the main window
  34. //
  35. //    Arguments:
  36. //        parent - The parent layout. Must be a form layout.
  37. //
  38. {
  39.     string $requiredType = "formLayout";
  40.     if ($requiredType != `objectTypeUI $parent`) {
  41.         error -showLineNumber true ("Argument must be a " + $requiredType);
  42.         return;
  43.     }
  44.  
  45.     global string $gToolSettingsMainWindowLocation;
  46.     global string $gToolSettingsMainWindowIcon;
  47.     global string $gToolSettingsMainWindowName;
  48.     global string $gToolSettingsMainWindowResetButton;
  49.     global string $gToolSettingsMainWindowHelpButton;
  50.  
  51.     setParent $parent;
  52.  
  53.     //    Setting the width of this separator is the key to keeping the
  54.     //    Tool Settings window from varying it's width.
  55.     //
  56.     //    Any tool that makes the settings area wider should be
  57.     //    reformatted.
  58.     //
  59.     //    *** Note that the hardcoded value of 398 makes the 
  60.     //    Tool Settings the same width as the Attribute Editor.
  61.     //
  62.     separator -style "none" -width 398;
  63.  
  64.     string $name = `text -label "" -align "left"`;
  65.     string $reset = `button -label "Reset Tool"`;
  66.     string $help = `button -label "Tool Help..."`;
  67.  
  68.     string $toolArea = `tabLayout
  69.         -scrollable        true
  70.         -tabsVisible       false
  71.         -innerMarginWidth  2
  72.         -innerMarginHeight 2
  73.         `;
  74.  
  75.     columnLayout;
  76.         
  77.     formLayout -edit
  78.         -attachForm     $name        "top"        1
  79.         -attachForm        $name         "left"    1
  80.         -attachControl  $name         "bottom"    5 $toolArea
  81.         -attachNone     $name         "right"
  82.  
  83.         -attachForm     $reset        "top"        1
  84.         -attachPosition $reset        "left"    0 60
  85.         -attachNone     $reset        "bottom" 
  86.         -attachPosition    $reset        "right"    3 80
  87.  
  88.         -attachForm     $help        "top"        1
  89.         -attachPosition $help        "left"        2 80
  90.         -attachNone     $help        "bottom" 
  91.         -attachForm        $help        "right"    0
  92.  
  93.         -attachControl  $toolArea     "top"    2 $help
  94.         -attachForm     $toolArea     "left"   0
  95.         -attachForm        $toolArea     "bottom" 0 
  96.         -attachForm     $toolArea     "right"  0
  97.         $parent;
  98.  
  99.  
  100.     $gToolSettingsMainWindowLocation    = $toolArea;
  101.     $gToolSettingsMainWindowIcon        = "";
  102.     $gToolSettingsMainWindowName        = $name;
  103.     $gToolSettingsMainWindowResetButton = $reset;
  104.     $gToolSettingsMainWindowHelpButton    = $help;
  105. }
  106.  
  107. global proc redirectToolSettings(string $destination)
  108. //
  109. //    Description:
  110. //        Redirect the location of the Tool Settings.
  111. //
  112. //        This procedure will update the toolPropertyWindow
  113. //        command so that it points to the correct controls
  114. //        for displaying the Tool Settings.
  115. //
  116. //    Arguments:
  117. //        $destination - Either "Main Window" or "Separate Window".
  118. //
  119. {
  120.     global string $gToolSettingsMainWindowLocation;
  121.     global string $gToolSettingsMainWindowIcon;
  122.     global string $gToolSettingsMainWindowName;
  123.     global string $gToolSettingsMainWindowResetButton;
  124.     global string $gToolSettingsMainWindowHelpButton;
  125.  
  126.     global string $gToolSettingsSeparateWindowLocation;
  127.     global string $gToolSettingsSeparateWindowIcon;
  128.     global string $gToolSettingsSeparateWindowName;
  129.     global string $gToolSettingsSeparateWindowResetButton;
  130.     global string $gToolSettingsSeparateWindowHelpButton;
  131.  
  132.     if ("Main Window" == $destination) {
  133.         toolPropertyWindow -edit -location    $gToolSettingsMainWindowLocation;
  134.         toolPropertyWindow -edit -icon        $gToolSettingsMainWindowIcon;
  135.         toolPropertyWindow -edit -field       $gToolSettingsMainWindowName;
  136.         toolPropertyWindow -edit -resetButton $gToolSettingsMainWindowResetButton;
  137.         toolPropertyWindow -edit -helpButton  $gToolSettingsMainWindowHelpButton;
  138.  
  139.     } else if ("Separate Window" == $destination) {
  140.         toolPropertyWindow -edit -location    $gToolSettingsSeparateWindowLocation;
  141.         toolPropertyWindow -edit -icon        $gToolSettingsSeparateWindowIcon;
  142.         toolPropertyWindow -edit -field       $gToolSettingsSeparateWindowName;
  143.         toolPropertyWindow -edit -resetButton $gToolSettingsSeparateWindowResetButton;
  144.         toolPropertyWindow -edit -helpButton  $gToolSettingsSeparateWindowHelpButton;
  145.  
  146.     } else if ("" == $destination) {
  147.         toolPropertyWindow -edit -location    "";
  148.         toolPropertyWindow -edit -icon        "";
  149.         toolPropertyWindow -edit -field       "";
  150.         toolPropertyWindow -edit -resetButton "";
  151.  
  152.     } else {
  153.         error ("Invalid destination for Tool Settings.");
  154.     }
  155. }
  156.  
  157. global proc int toolSettingsVisibilityStateChange(
  158.     int    $newState,
  159.     string $layout)
  160. //
  161. //    Description:
  162. //        This procedure is called whenever the visibility state is changed.
  163. //
  164. //    Arguments:
  165. //        newState - The new visible state.
  166. //
  167. //        layout - The parent layout.
  168. //
  169. //    Returns:
  170. //        true - If the change of state is to be allowed.
  171. //
  172. //        false - If the state change is rejected.
  173. //
  174. {
  175.     int $result = true;
  176.  
  177.     if ($newState) {
  178.         redirectToolSettings("Main Window");
  179.     } else {
  180.         redirectToolSettings("");
  181.     }
  182.  
  183.     //    Defer these commands because this proc is called when the visibility
  184.     //    state is about to change. This proc must return true to accept 
  185.     //    the state change. After this proc returns then restore the
  186.     //    panel focus and update the pref menu.
  187.     //
  188.     evalDeferred("restoreLastPanelWithFocus(); updatePrefsMenu();");
  189.  
  190.     return $result;
  191. }
  192.  
  193. //    Note that the following script block is not a procedure and will be
  194. //    executed when this script file is sourced.
  195. //
  196. {
  197.     global string $gToolSettingsForm;
  198.  
  199.     //    Create the Tool Settings.
  200.     //
  201.     createToolSettings($gToolSettingsForm);
  202.  
  203.     setUIComponentStateCallback(
  204.         "Tool Settings", "toolSettingsVisibilityStateChange");
  205.  
  206.     //    Set the initial visibility.
  207.     //
  208.     setToolSettingsVisible(`optionVar -query toolSettingsVisible`);
  209. }
  210.